package com.guigu.dispatch.controller;


import cn.hutool.core.collection.CollUtil;
import com.guigu.dispatch.entity.OrderClassifyOrder;
import com.guigu.dispatch.service.OrderClassifyOrderService;
import com.guigu.tms.result.R;
import com.guigu.tms.result.ResultCode;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 订单分类订单关联表 前端控制器
 * </p>
 *
 * @author TaoLong
 * @since 2021-11-18
 */
@RestController
@RequestMapping("/dispatch/order-classify-order")
public class OrderClassifyOrderController {

    private OrderClassifyOrderService orderClassifyOrderService;

    public OrderClassifyOrderController(OrderClassifyOrderService orderClassifyOrderService) {
        this.orderClassifyOrderService = orderClassifyOrderService;
    }

    /**
     * 根据订单id查询订单分类Id和订单id
     * @param orderId
     * @return
     */
    @ApiOperation("根据订单id查询订单分类Id和订单id")
    @ApiImplicitParam(name = "orderId", value = "订单分类Id")
    @GetMapping("/findByOrderId/{orderId}")
    public R<List<OrderClassifyOrder>> findByOrderId(@PathVariable String orderId) {
        List<OrderClassifyOrder> list = orderClassifyOrderService.findByOrderId(orderId);
        if (CollUtil.isNotEmpty(list)) {
            return new R<>(ResultCode.SUCCESS_CODE, list);
        }
        return new R<>(ResultCode.ERROR_CODE, null);
    }
}

